package First;

public class SuperPackage extends ServicePackage implements CallService,SendService,NetService{
    public int flow;  // 上网流量(MB)
    public int talkTime;
    public int smsCount;
    double price=78;
//    public SuperPackage(int flow) {
//        this.flow = flow;
//        //this.talkTime=talkTime;
//        //this.smsCount=smsCount;
//
//    }
    public SuperPackage(double price) {
        this.price = price;
        this.flow = 1024;    // 明确初始化1GB=1024MB
        this.talkTime = 200; // 200分钟
        this.smsCount = 50;  // 50条短信
    }
    @Override
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public void setFlow(int flow) {
        this.flow = flow;
    }
    public int getTalkTime() {
        return talkTime;
    }
    public void setTalkTime(int talkTime) {
        this.talkTime = talkTime;
    }
    public int getSmsCount() {
        return smsCount;
    }
    public void setSmsCount(int smsCount) {
        this.smsCount = smsCount;
    }

    @Override
    public void showInfo() {
        System.out.println("超人套餐:通话时长为" + talkTime + "分钟/月,短信条数为:"+smsCount+
                "条/月,上网流量为:" + flow + "MB/月,月租"+price+"元");
    }
//超人月资费为0 充值的钱没有显示 网虫注册成功后显示的上网流量为3GB/月 显示错误 剩余上网流量显示3mb错误
    @Override
    public int netPlay(int flow,MobileCard card) {
        int extra=0;
        if (flow<=this.flow) {
            this.flow-=flow;
        } else {
            extra=flow-this.flow;
            this.flow=0;
            // 额外流量按0.1元/MB计费
            card.setConsumAmount(card.getConsumAmount()+extra*0.1);
        }
        card.setRealFlow(card.getRealFlow()+flow);
        return extra;
    }
    public int getFlow() {
        return flow;
    }
    @Override
    public int call(int minCount, MobileCard card) {
        return minCount;
    }

    @Override
    public int send(int count, MobileCard card) {
        return count;
    }
}